"use strict";
/* Controllers */
app.controller("rankMoreController", ['$scope', '$location', '$rootScope', '$routeParams', 'rankMoreService', function ($scope, $location, $rootScope, $routeParams, rankMoreService) {

    var vm = $scope.vm = {};
    vm.p = {};
    vm.result = {};
    vm.p.appID = $routeParams.appID; //  获取应用模块的名称

    var errorFn = function (result) {
        alert(result);
    };

    $scope.listRank = function () {
        var vm = $scope.vm;
        vm.result.ms = "...";
        var params = {appID: vm.p.appID};
        var procFn = function (response) {
            vm.result.ms = response.ms;
            var data = response.data;
            if (data == null) return;
            vm.result.data = data;
            $('#list_table').bootstrapTable('load', data);
        };
        rankMoreService.listRank(params, procFn, errorFn);
    };

    $scope.initializeController = function () {
        vm.result.ms = '';
        var $resultTable = $('#list_table');
        $resultTable.bootstrapTable({
             pageMore: [30, 50, 100, 300, 500, 1000], pageSize: 30
        });
        $scope.listRank();
    };

    $scope.initializeController();

}]);


/* Services */
app.service('rankMoreService', ['ajaxService', function (ajaxService) {

    this.listRank = function (params, successFunction, errorFunction) {
        ajaxService.AjaxPost(params, "/star/api/reci-service/v1/rank/rank_list.do", successFunction, errorFunction);
    };
}]);

